﻿<script>
/*$(document).ready( function () 
{
	var iStart = new Date().getTime();
	var oTable = $('#scroll-table').dataTable( 
	{
		"sScrollY": "300px",
		"sScrollX": "100%",
		"sScrollXInner": "150%",
		"bScrollCollapse": true,
		"bPaginate": false,
        "bFilter": false
	} );
	new FixedColumns( oTable, 
	{
		"sHeightMatch": "none"
	} );
} );*/

 </script>
                        
                        <div class="">
                        <h1>إعدادات الاسعار</h1>
                        <hr />
                        <div class="bookings-edit-container">
                        <p>أضغط على السعر وقم بتعديله</p>
                        <div id="" style="max-height:350px; overflow-y:scroll; overflow-x:scroll;width:910px;border:1px solid;">
                        <table id="scroll-table" style="font-size:10px !important;margin-bottom:20px;white-space:nowrap;" class="customers-table center">
                            	<thead>
                                <tr class="bg-head">
                                    <td colspan="3" class="">&nbsp;</td>
									<?php
									$pds=$periods;
									//hidden value with all Period IDZ
									$pidz='';
									$sep="";//separator to be used
									//a string to fill with <td>'s
									$ptds='';
									//a string to fill with <div>'s
									$pdivs='<input type="hidden" name="cid" value="'.$cid.'"/>
                             <input type="hidden" name="add-periods" value="1"/>';
									$p=1;
									foreach ($pds as $pdsa)
									{
									$pidz.=$sep.$pdsa['period_id'];
									$sep="|";
									?>
                                    <td colspan="3" class="">فترة <?php echo $p;?></td>
									<?php 
									$ptds.='<td style="width:60px" id="'.$p.'" class="">اليومى</td>
                                    <td style="width:60px" id="'.$p.'" class="">الأسبوعى</td>
                                    <td style="width:60px" id="'.$p.'" class="">الشهرى</td>';
									$pdivs.='<div class="clear" style="margin-bottom:14px">
                             <span class="margin-left:20px;">فترة '.$p.'</span>
                             <label>من &nbsp;</label><span><input type="text" readonly class="small-input" name="from-'.$pdsa['period_id'].'" id="from-'.$p.'" required value="'.$pdsa['period_from'].'"></span>
                             <label>إلى &nbsp;</label><span><input type="text" readonly class="small-input" name="to-'.$pdsa['period_id'].'" id="to-'.$p.'" required value="'.$pdsa['period_to'].'"></span>
							 &nbsp;<span><input type="checkbox" id="del" name="del-'.$pdsa['period_id'].'"></span><label>حذف &nbsp;</label>
                           </div>';
									$p++;
									} ?>
                                </tr>
                                <tr class="bg-head">
                                    <td class="">اسم الوحدة</td>
                                    <td class="">الطابق</td>
                                    <td class="">الغرف</td>
<?php echo $ptds;?>
                                </tr>
                                </thead>
                                <?php foreach($aparts as $apart)
                                  { ?>
                                <tr id="<?php echo $cid; ?>">
                                  
                                    <td class="apart_id" value="<?php echo $apart['id']; ?>"><?php echo $apart['apart_name']; ?></td>
                                    <td class=""><?php echo $apart['floor']; ?></td>
                                    <td class=""><?php echo $apart['rooms']; ?></td>
									<?php //loop through pids 
									foreach ($pds as $pdsa)
									{
									?>
                                    <td class="co-edit-price" id='<?php echo $pdsa["period_id"];?>' value="co_daily"><?php echo cogetpp($apart['id'],$pdsa["period_id"],'co_daily',$cid); ?></td>
                                    <td class="co-edit-price" id='<?php echo $pdsa["period_id"];?>' value="co_weekly"><?php echo cogetpp($apart['id'],$pdsa["period_id"],'co_weekly',$cid); ?></td>
                                    <td class="co-edit-price" id='<?php echo $pdsa["period_id"];?>' value="co_monthly"><?php echo cogetpp($apart['id'],$pdsa["period_id"],'co_monthly',$cid); ?></td>
									<?php
									}
									?>
									</tr>
                                <?php } ?>
                         </table >
                         </div>
                         <h2>تحديد الفترات</h2>
                         <form name="periods" method="post" action="setcoprice.php" id="periods">
						
						<?php 
						//print prepared divs
						echo $pdivs; 
						?>
						
							<input type="hidden" name="pidz" value="<?php echo $pidz;?>" >
							<?php
							if ($pidz!="")
							{
							?>
							<input type="checkbox" id="delcheck"><lable>&nbsp;تحديد الكل</lable><br>
							<div id="ap-edit" style="margin-top:0;float:none" class="ap-edit">تعديل</div>  
							<?php
							}
							?>
                        </form>
						<form action="setcoprice.php" method="post" style="margin-top:2px;">
						<input type="hidden" name="cid" value="<?php echo $cid;?>">
						<input type="hidden" name="newperiod" value="">
						<div style="margin-top:0;float:none" class="small-botton">اضافة فترة</div>  
						</form>

                        </div>
                      </div>  
